﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using OrderManagement;

namespace OrderCheckPrice
{
    [TestClass]
    public class UnitTest1
    {
        public static List<Order> Creat()
        {
            Customers customers1 = new Customers("张小亮", "C3-224", "110");
            Customers customers2 = new Customers("渣渣诚", "C3-319", "119");
            Goods good1 = new Goods("康师傅泡面", 4.5, 12, 2); // 9
            Goods good2 = new Goods("泡面搭档火腿肠", 2, 12, 3); //6
            Goods good3 = new Goods("果粒橙", 4, 12, 1); //4
            Goods good4 = new Goods("营养快线", 5, 12, 2);//10
            List<Goods> goods1 = new List<Goods>();
            List<Goods> goods2 = new List<Goods>();
            List<Goods> goods3 = new List<Goods>();
            goods1.Add(good1);
            goods1.Add(good2);

            goods2.Add(good3);
            goods2.Add(good4);

            goods3.Add(good1);
            goods3.Add(good4);
            OrderDetails orderDetails1 = new OrderDetails(goods1);
            OrderDetails orderDetails2 = new OrderDetails(goods2);
            OrderDetails orderDetails3 = new OrderDetails(goods3);
            //生成测试订单
            Order order1 = new Order(customers1, orderDetails1, "000001");
            Order order2 = new Order(customers2, orderDetails2, "000002");
            Order order3 = new Order(customers1, orderDetails3, "000003");
            List<Order> orders = new List<Order>();
            orders.Add(order3);
            orders.Add(order2);
            orders.Add(order1);
            return orders;

        }
        public static bool Judge(List<Order> list)
        {
            bool flag = true;
            foreach(Order m in list)
            {
                if (m.OrderDetails.Price > 17 && m.OrderDetails.Price < 19)
                    flag = true;
                else
                    flag = false;
            }
            return flag;
        }
        [TestMethod]
        public void TestMethod1()
        {
            List<Order> list = new List<Order>();
            OrderService service = new OrderService(list);
            List<Order> test = service.OrderCheckPrice(17, 19);
            Assert.IsTrue(Judge(test));
        }
    }
}
